#include "junix.h"
#include <ext/hash_map>

using namespace std;
using __gnu_cxx::hash_map;

struct hash_str {
	std::size_t operator()(const std::string& s) const {
		return __gnu_cxx::hash<const char*>()(s.c_str());
	}
};


int main(int argc, char **argv)
{
	ifstream file("BIGTXT");
	if (!file) {
		cerr<<"file open error\n";
		exit(EXIT_FAILURE);
	}

	typedef hash_map<std::string,int,hash_str> DICT;
	DICT dict;
	std::string s;
	while (file>>s) {
		++dict[s];
	}

	file.close();
	cout<<dict.size()<<endl;

	DICT::iterator pos=dict.begin(), end=dict.end();
	for (;pos !=end; ++pos) {
		cout<<"("<<pos->first<<","<<pos->second<<")\n";
	}
}
